package com.example.liuweather.android;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;

import com.qweather.sdk.view.HeConfig;

public class MainActivity extends BaseActivity {

    /*和风天气的 publick 和 key，可以在和风天气控制台查看*/
    public static  final String PUBLIC_ID = "HE2302191831141772";
    public static  final String KEY = "98f7a7016c114044b830a0c7fbcec9a6";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // 进行账户初始化
        HeConfig.init(PUBLIC_ID,KEY);
        // 切换免费订阅
        HeConfig.switchToDevService();

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences
                (this);
        // 之前已经请求过天气数据,是直接跳转到WeatherActivity
        if (prefs.getString("weather_id", null) != null) {
            Intent intent = new Intent(this, WeatherActivity.class);
            intent.putExtra("weather_id","1");
            startActivity(intent);
            finish();
        }
    }
}